var list = [
    {
        "id": 1,
        "title": "用户管理",
        "icon": "el-icon-location",
        "Pid": null,
        "path": null
    },
    {
        "id": 2,
        "title": "用户列表",
        "icon": "el-icon-location",
        "Pid": 1,
        "path": "/user"
    },
    {
        "id": 3,
        "title": "订单管理",
        "icon": "el-icon-location",
        "Pid": null,
        "path": null
    },
    {
        "id": 4,
        "title": "发布订单",
        "icon": "el-icon-location",
        "Pid": 3,
        "path": "/order/add"
    },
    {
        "id": 5,
        "title": "订单列表",
        "icon": "el-icon-location",
        "Pid": 3,
        "path": "/order/list"
    },
    {
        "id": 6,
        "title": "接单大厅",
        "icon": "el-icon-location",
        "Pid": 3,
        "path": "/order"
    },
    {
        "id": 7,
        "title": "个人中心",
        "icon": "el-icon-location",
        "Pid": 3,
        "path": "/myself"
    }
]

// var menus = list.map(v => {
//     v.children = list.filter(e => e.Pid == v.id)
//     return v
// }).filter(v => !v.Pid)

// console.log(menus);


list.forEach(v => {
    //  过滤出 跟v.id 一致 pid
    v.children = list.filter(e => e.Pid == v.id)
})
console.log(list.filter(v => !v.Pid));